import 'package:flutter/material.dart';
import 'package:x3_charts_core/chart_painter/equally_divided_pie_chart_painter.dart';
import 'package:x3_charts_core/model/equally_divided_pie_chart_data_model.dart';

///**
///* @author hrongyong
///* @date   1/26/21
///* @email hrongyong@gmail.com
///* Description: 等分饼图
///*/

class EquallyDividedPieChartWidget extends StatefulWidget {
  final List<EquallyDividedPieChartDataModel> pieChartList;

  ///主副标题大小
  final double fontSize;

  EquallyDividedPieChartWidget({@required this.pieChartList, this.fontSize = 4});

  @override
  _EquallyDividedPieChartWidgetState createState() => _EquallyDividedPieChartWidgetState();
}

class _EquallyDividedPieChartWidgetState extends State<EquallyDividedPieChartWidget> {
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      child: LayoutBuilder(
        builder: (BuildContext context, BoxConstraints constraints) {
          return CustomPaint(
            size: Size(constraints.maxWidth, constraints.maxHeight),
            painter: EquallyDividedPieChartPainter(
              pieChartList: widget.pieChartList,
              fontSize: widget.fontSize,
            ),
          );
        },
      ),
    );
  }
}
